<template>
  <div>
    <div class="block">
      <span class="demonstration">预计交车开始</span>
      <el-date-picker
        v-model="yearAndMonth"
        type="date"
        placeholder="选择月份">
      </el-date-picker>
    </div>
    <timeTableComponent :rowData="currentSelectResult" />
  </div>
</template>

<script>

import timeTableComponent from './timeTableComponent'
import { qryDeliveryBoard } from '@/api/retail/salesmanage/deliveryManagement';
import moment from 'moment'
export default {
  name: 'timeTable',
  components: {
    timeTableComponent
  },
  data() {
    return {
      yearAndMonth: new Date(),
      currentSelectResult: [{},{},{},{}]
    }
  },
  methods: {
    // 日期预处理
    preDateHandler(val, formatCode='YYYY-MM-DD HH:mm:ss') {
      let resultDate = val ? moment(Number(val)).format(formatCode) : val;
      if ((resultDate == 'Invalid date' || resultDate == 'Invalid Date') && val) {
        resultDate = moment(val).format(formatCode)
      }
      return resultDate;
    },
  },
  watch: {
    yearAndMonth() {
      let param = {
        deliveringDateStart: this.preDateHandler(this.yearAndMonth, 'YYYY-MM-DD')
      }
      qryDeliveryBoard(param).then(res => {
        this.currentSelectResult = res.data
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>
